<template>
<div class="add">
<van-nav-bar
  title="新增页面"
  left-arrow
  @click-left="onClickLeft"
/>
<van-search v-model="name" clearable="true" left-icon="clean" placeholder="输入任务名称" />
<div class="addtask" @click="handleClick">新增</div>
</div>
</template>

<script setup>
import { ref } from 'vue';
import { useStore } from "../stores/tasklist";
import { useRouter } from 'vue-router';

let $router =useRouter()
let store = useStore()
const onClickLeft = () => history.back();
const name = ref('');
let handleClick=()=>{
    if (name.value) {
        store.add(name.value)
        $router.push('/')
    }  
}
</script>
<style scoped>
.addtask{
    height: 40px;
    text-align: center;
    line-height: 40px;
    border-radius: 5px;
    color: #15a6a9;
    border: 1px solid #15a6a9;
    margin-left: 10px;

}
</style>